package com.example.block_chain.service.impl.faculty;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.block_chain.domain.pojo.Faculty;
import com.example.block_chain.mapper.FacultyMapper;
import com.example.block_chain.service.faculty.FacultyService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 学院表(Faculty)表服务实现类
 *
 * @author makejava
 * @since 2024-03-04 16:18:26
 */
@Service("facultyService")
public class FacultyServiceImpl extends ServiceImpl<FacultyMapper, Faculty> implements FacultyService {

    @Override
    public List<Faculty> getFacultyBySchoolCode(String schoolCode) {
        LambdaQueryWrapper<Faculty> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Faculty::getSchoolCode, schoolCode).orderByAsc(Faculty::getName);
        return list(queryWrapper);

    }

    @Override
    public Faculty getFaculty(String facultyCode) {
        LambdaQueryWrapper<Faculty> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Faculty::getFacultyCode, facultyCode);
        return getOne(queryWrapper);
    }
}
